package com.ruoyi.web.controller.system;

import java.util.List;
import java.util.Arrays;

import lombok.RequiredArgsConstructor;
import javax.validation.constraints.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.vo.SysPtFinalScoreVo;
import com.ruoyi.system.bo.SysPtFinalScoreQueryBo;
import com.ruoyi.system.bo.SysPtFinalScoreAddBo;
import com.ruoyi.system.bo.SysPtFinalScoreEditBo;
import com.ruoyi.system.service.ISysPtFinalScoreService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 最终成绩管理Controller
 *
 * @author 莫修
 * @date 2021-11-28
 */
@Api(value = "最终成绩管理控制器", tags = {"最终成绩管理管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/system/SysPtFinalScore")
public class SysPtFinalScoreController extends BaseController {

    private final ISysPtFinalScoreService iSysPtFinalScoreService;

    /**
     * 查询最终成绩管理列表
     */
    @ApiOperation("查询最终成绩管理列表")
    @PreAuthorize("@ss.hasPermi('system:SysPtFinalScore:list')")
    @GetMapping("/list")
    public TableDataInfo<SysPtFinalScoreVo> list(@Validated SysPtFinalScoreQueryBo bo) {
        return iSysPtFinalScoreService.queryPageList(bo);
    }

    /**
     * 导出最终成绩管理列表
     */
    @ApiOperation("导出最终成绩管理列表")
    @PreAuthorize("@ss.hasPermi('system:SysPtFinalScore:export')")
    @Log(title = "最终成绩管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<SysPtFinalScoreVo> export(@Validated SysPtFinalScoreQueryBo bo) {
        List<SysPtFinalScoreVo> list = iSysPtFinalScoreService.queryList(bo);
        ExcelUtil<SysPtFinalScoreVo> util = new ExcelUtil<SysPtFinalScoreVo>(SysPtFinalScoreVo.class);
        return util.exportExcel(list, "最终成绩管理");
    }

    /**
     * 获取最终成绩管理详细信息
     */
    @ApiOperation("获取最终成绩管理详细信息")
    @PreAuthorize("@ss.hasPermi('system:SysPtFinalScore:query')")
    @GetMapping("/{classId}")
    public AjaxResult<SysPtFinalScoreVo> getInfo(@NotNull(message = "主键不能为空")
                                                  @PathVariable("classId") Long classId) {
        return AjaxResult.success(iSysPtFinalScoreService.queryById(classId));
    }

    /**
     * 新增最终成绩管理
     */
    @ApiOperation("新增最终成绩管理")
    @PreAuthorize("@ss.hasPermi('system:SysPtFinalScore:add')")
    @Log(title = "最终成绩管理", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@Validated @RequestBody SysPtFinalScoreAddBo bo) {
        return toAjax(iSysPtFinalScoreService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改最终成绩管理
     */
    @ApiOperation("修改最终成绩管理")
    @PreAuthorize("@ss.hasPermi('system:SysPtFinalScore:edit')")
    @Log(title = "最终成绩管理", businessType = BusinessType.UPDATE)
    @PutMapping()
    public AjaxResult<Void> edit(@Validated @RequestBody SysPtFinalScoreEditBo bo) {
        return toAjax(iSysPtFinalScoreService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 删除最终成绩管理
     */
    @ApiOperation("删除最终成绩管理")
    @PreAuthorize("@ss.hasPermi('system:SysPtFinalScore:remove')")
    @Log(title = "最终成绩管理" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{classIds}")
    public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
                                       @PathVariable Long[] classIds) {
        return toAjax(iSysPtFinalScoreService.deleteWithValidByIds(Arrays.asList(classIds), true) ? 1 : 0);
    }
}
